<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>

    autoCompleteClinic("clinic");
    function autoCompleteClinic(inputId){
        var url="${ctx}/oper/clinicItemDict/automatic";
        autoComplete(inputId,url,
            function(data){
                var rows = [];
                for(var i=0; i<data.length; i++){
                    rows[rows.length] = {
                        data:data[i],
                        value:data[i].id,
                        result:data[i].itemName
                    };
                }
                return rows;
            },function(data, i, max){
                return data.inputCode + ' | '+data.itemName
            },function(event,data,formatted){
                $('#itemId').attr('value',data.id);
                $('#itemCode').attr('value',data.itemCode);
            });
    }

    function formSaveMethod(divId, formId, url, hrefUrl) {
        if (flag) {
            flag = false;
            formSubmitInput(formId);
            $("#" + formId + " input,#" + formId + " select").removeAttr("disabled");
            $.ajax({
                type: "POST",
                data: $("#" + formId).serialize(),
                url: url,
                dataType: "json",
                success: function (data) {
                    if (data.code == "success") {
                        toastr.success(data.data);
                        loadDiv(divId, hrefUrl);
                    }
                    else {
                        flag = true;
                        toastr.error(data.data);
                    }
                },
                error: function (data) {
                    toastr.error('网络连接错误,请检查网络');
                    flag = true;
                }
            });
        }
        return false;
    }
</script>
<div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#" >
                        <c:choose>
                        <c:when test="${type eq 'BLOOD_TEST_DICT'}">
                            验血划价项目
                        </c:when>
                        <c:otherwise>
                            配血划价项目
                        </c:otherwise>
                    </c:choose></a>
                </li>
            </ul>
            <section class="panel panel-default">
                <div class="panel-body">
                    <div class="col-lg-12">
                        <form:form id="inputForm" data-parsley-validate="" modelAttribute="sysOrgDictVSClinicVo" onsubmit="return formDivSaveLoad('mainCenterDiv','inputForm','${ctx}/sys/sysOrgDict/saveBlood','${ctx}/sys/sysOrgDict/bloodMatchList?type=${type}');" method="post" class="form-horizontal">
                            <form:hidden path="id"/>
                            <form:hidden path="itemId" id="itemId"/>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        <c:choose>
                                            <c:when test="${type eq 'BLOOD_TEST_DICT'}">
                                                验血项目：
                                            </c:when>
                                            <c:otherwise>
                                                配血方法：
                                            </c:otherwise>
                                        </c:choose>
                                       </label>
                                    <div class="col-sm-8">
                                        <input  class="form-control" readonly value=" ${sysOrgDictVSClinicVo.label}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目名称：</label>
                                    <div class="col-sm-8">
                                        <input id="clinic"  class="form-control" data-parsley-required="true" value="${sysOrgDictVSClinicVo.itemName}"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目代码：</label>
                                    <div class="col-sm-8">
                                        <input name="itemCode" id="itemCode" readonly class="form-control"  data-parsley-required="true"  value="${sysOrgDictVSClinicVo.itemCode}"/>
                                    </div>
                                </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">执行科室：</label>
                                <div class="col-sm-8">
                                    <sys:treeselect selectedParent="true" id="orgDeptId" name="executiveDept.id" value="${sysOrgDictVSClinicVo.executiveDept.id}" isnull="true"  update="${not empty
                                    sysOrgDictVSClinicVo.executiveDept.id}" labelName="${sysOrgDictVSClinicVo.executiveDept.deptName}" labelValue="${sysOrgDictVSClinicVo.executiveDept.deptName}"
                                                    title="科室" url="/sys/orgDept/treeData"  cssClass="form-control"/>
                                </div>
                            </div>
                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存">&nbsp;
                                        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="closeFormDiv()">
                                </div>
                            </div>
                        </form:form>
                    </div>

                </div>
            </section>
        </div>
    </div>